#pragma once
#include <nodes\DynamicSpriteNode.h>
#include <vector>

// -----------------------------------------------------------------------------
//
// This class handles the bubbles which can be collected by the player
//
// -----------------------------------------------------------------------------
class FloatingParticles {

struct FloatingParticle {
	ds::Sprite* sprite;
	float angle;
	ds::Vec2 velocity;
};

typedef std::vector<FloatingParticle> Particles;

public:
	FloatingParticles(ds::DynamicSpriteNode* spriteNode);
	~FloatingParticles(void);
	void update( float elapsed );
	void init();
	void add(const ds::Vec2& center,int counter,float minRadius,float maxRadius);
	void setTargetPosition(const ds::Vec2& tp) {
		m_TargetPosition = tp;
	}
	void setMagneticMode(bool mm) {
		m_MagneticMode = mm;
	}
	int pickupParticles(const ds::Vec2& pos,const ds::Vec2& dim);
	void clear();
private:
	ds::Vec2 getNewPosition(const ds::Vec2& pos,float distance,float add) {
		ds::Vec2 ret = pos;
		float dx = m_TargetPosition.x - pos.x;
		float dy = m_TargetPosition.y - pos.y;
		float dist = sqrt( dx * dx + dy * dy);
		if ( dist > distance ) {
			ret.x = pos.x + dx * add;
			ret.y = pos.y + dy * add;
		}		
		return ret;
	}
	bool m_MagneticMode;
	ds::Vec2 m_TargetPosition;
	ds::DynamicSpriteNode* m_Sprites;
	Particles m_Particles;
};

